package com.lanhao.aot.spider;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.util.StopWatch;
import org.springframework.web.bind.annotation.RequestMapping;

import com.lanhao.aot.spider.service.NetSpiderFor17TrackService;

@Controller
@RequestMapping("")
public class NetSpiderFor17TrackController {
	private static Logger logger = LoggerFactory.getLogger(NetSpiderFor17TrackController.class);

//	@Autowired
	private NetSpiderFor17TrackService service;

	@RequestMapping(value = "/track")
	public ResponseEntity<?> track(HttpServletRequest request) {
		StopWatch stopWatch = new StopWatch();
		stopWatch.start("Track-task");
		String trackNum = request.getParameter("trackNum");
		String result = service.track(request, trackNum);
		long totalTimeMillis = stopWatch.getTotalTimeMillis();
		logger.info("爬取信息耗时cost={}", totalTimeMillis);
		return new ResponseEntity<>(result, HttpStatus.OK);
	}
}